import { createStore } from 'vuex'

export default createStore({
  state: {
    token: sessionStorage.getItem('token'),
    user: sessionStorage.getItem('user')
      ? JSON.parse(sessionStorage.getItem('user'))
      : {},
  },
  mutations: {
    setToken(state, token) {
      state.token = token
      sessionStorage.setItem('token', token)
    },
    setUser(state, user) {
      state.user = use
      sessionStorage.setItem('use', JSON.stringify(user))
    },
  },
  actions: {},
  modules: {},
})
